package com.mfc.education.service.statistics.task;

import com.mfc.education.service.statistics.service.DailyService;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author mfc
 * @since 2021/10/6
 */
@Slf4j
@Component
public class ScheduledTask {

    @Autowired
    private DailyService dailyService;

//    @Scheduled(cron = "0/3 * * * * *")
//    public void testTask(){
//        System.out.println("task1执行");
//    }


//    @Scheduled(cron = "0 19 10 * * ?")
    @Scheduled(cron = "0 0 1 * * ?")
    public void testStatisticData() {
        log.info("testStatisticData执行,记录每天的统计数据");

        String day = new DateTime().minusDays(1).toString("yyyy-MM-dd");
        dailyService.createStatisticsByDay(day);
    }
}
